<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html:html>
    <head>
        <title>Gestion EDT - Pools</title>

        <link rel="stylesheet" type="text/css" href="resources/css/design.css" />
        <link rel="stylesheet" type="text/css" href="resources/css/design_print.css" media="print" />
        <link rel="stylesheet" type="text/css" href="resources/css/pools.css" />

        <script type="text/javascript" src="resources/js/script.js"></script>
    </head>
    <body>
        <jsp:include page="_menu.jsp" />

        <bean:define id="nv" value="${PoolsForm.pool.id == null || PoolsForm.pool.id == 0}" />

        <h1 class="titrePage">
            <c:if test="${nv}">Ajout d'un pool</c:if>
            <c:if test="${!nv}">Modification du pool '${PoolsForm.pool.libelle}'</c:if>
        </h1>

        <html:errors/>

        <html:form action="/EnregistrerPool" focus="pool.libelle" styleId="formPool">

            <html:hidden property="pool.id" />

            <div class="elemForm">
                <label for="libelle">Libellé</label>
                <html:text property="pool.libelle" styleId="libelle" maxlength="50" />
            </div>
            <div class="elemForm">
                <label for="nbPrestMax">Nombre max. de prestations simultanées</label>
                <html:text property="pool.nbPrestMaxParPlage" styleId="nbPrestMax" />
                <hr style="clear: both; visibility: hidden;" />
            </div>
            <div class="elemForm">
                <label for="description">Description</label>
                <html:textarea property="pool.description" styleId="description" />
            </div>

            <p class="boutons">
                <c:if test="${nv}"><html:submit value="Ajouter" /></c:if>
                <c:if test="${!nv}"><html:submit value="Modifier" /></c:if>
                <c:if test="${!nv}">
                    <html:link action="/GererPools?action=afficherNv" styleClass="bouton">
                        Nouveau
                    </html:link>
                </c:if>
                <html:cancel value="Retour liste" />
            </p>

        </html:form>

        <c:if test="${!nv}">

          <h3 class="ct titreListeMod">Liste des modules associés à ce pool</h3>

          <c:if test="${empty PoolsForm.pool.modules}">
              <h4 class="ct">Ce pool n'est associé à aucun module pour le moment.</h4>
          </c:if>

          <c:if test="${not empty PoolsForm.pool.modules}">
            <table class="liste" id="listeModulesPool">
                <thead>
                    <th>Module</th>
                    <th>UE</th>
                    <th>Effectif max</th>
                    <th>Terminé</th>
                </thead>
                <tbody>
                    <logic:iterate id="module" name="PoolsForm" property="pool.modules" indexId="i">
                        <tr class="${i%2==0 ? "paire" : "impaire"}">
                            <td>${module.libelle}</td>
                            <td>${module.ue}</td>
                            <td>${module.effectifMax}</td>
                            <td>${module.estTermine ? 'Oui' : 'Non'}</td>
                        </tr>
                    </logic:iterate>
                </tbody>
            </table>
          </c:if>

        </c:if>

    </body>
</html:html>